package com.googlecode.volkien;

import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.Rect;
import android.util.AttributeSet;
import android.widget.TextView;

public class VolumeView extends TextView {

	public VolumeView(Context context, AttributeSet attrs, int defStyle) {
		super(context, attrs, defStyle);
	}

	public VolumeView(Context context, AttributeSet attrs) {
		super(context, attrs);
	}

	public VolumeView(Context context) {
		super(context);
	}

	protected void onDraw(Canvas canvas) {
		Rect rect = canvas.getClipBounds();
		Paint paint = new Paint();
		paint.setColor(Color.WHITE);
		canvas.drawLine(rect.left, rect.top, rect.right, rect.bottom, paint);
		Bitmap bitmap = BitmapFactory.decodeResource(getResources(), R.drawable.speaker_ldpi);
		canvas.drawBitmap(bitmap, 0, 0, paint);
	}

	@Override
	protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
		int width = MeasureSpec.getSize(widthMeasureSpec);
		switch (MeasureSpec.getMode(widthMeasureSpec)) {
		case MeasureSpec.AT_MOST:
			width = Math.min(width, 200);
			break;
		case MeasureSpec.UNSPECIFIED:
			width = 200;
			break;
		case MeasureSpec.EXACTLY:
		default:
		}
		
		int height = MeasureSpec.getSize(heightMeasureSpec);
		switch (MeasureSpec.getMode(heightMeasureSpec)) {
		case MeasureSpec.AT_MOST:
			height = Math.min(height, 20);
			break;
		case MeasureSpec.UNSPECIFIED:
			height = 20;
			break;
		case MeasureSpec.EXACTLY:
		default:
		}
		
		setMeasuredDimension(width, height);
	}
	
	
	
}
